slovar = {"(":1, "[":2,"{":3,"<":4, ")":1, "]":2,"}":3,">":4}
OTK = "([{<"
stroka = input("Введите скобочную последовательность: ")
stek = []
flag = True
for i in range(len(stroka)):
          if stroka[i] in OTK:
                    stek.append(slovar[stroka[i]])
          elif stroka[i] in slovar:
                    if slovar[stroka[i]] == stek[-1]:
                              stek = stek[:-1]
                    else:
                              flag = False
                              break
if len(stek) == 0 and flag:
    print("True")
else:
    print("False")
